from django.apps import AppConfig


class MonitoringConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'monitoring'
    verbose_name = '监控管理'

    def ready(self):
        """应用启动时的初始化操作"""
        # 暂时禁用自动启动告警聚合服务，避免自动生成测试告警
        # 启动告警聚合服务
        # try:
        #     from .tasks import start_alert_aggregation
        #     start_alert_aggregation()
        #     print("✅ 告警聚合服务已启动")
        # except Exception as e:
        #     print(f"❌ 启动告警聚合服务失败: {e}")
        #     import traceback
        #     traceback.print_exc()
        print("⚠️ 告警聚合服务已禁用，避免自动生成测试告警")

        # 启动Zabbix告警监控
        try:
            from .tasks import start_zabbix_alert_monitoring
            start_zabbix_alert_monitoring()
            print("✅ Zabbix告警监控已启动")
        except Exception as e:
            print(f"❌ 启动Zabbix告警监控失败: {e}")
            import traceback
            traceback.print_exc()
